package dibazhou;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
import java.util.Map.Entry;

public class Main5 {

	public static void main(String[] args) {
		Map<String,Set<Integer>> map = new HashMap<String,Set<Integer>>();
		Scanner sc=new Scanner(System.in);
		int line=1;
		while(sc.hasNext())
		{
			String key=sc.next();
			if(key.equals("!!!!!"))	break;
			String[] str = key.split(" ");
			for (String word : str)
			{
				Set<Integer> subIndex = new TreeSet<Integer>();
		        if (!map.containsKey(word)) {
		            subIndex.add(line);
		            map.put(word, subIndex);
			    }
		        else {
		        	 subIndex = map.get(word);
		             if (!subIndex.contains(line)) {
		             subIndex.add(line);
		             map.put(word, subIndex);
		             }
		        }
		    }
			line++;
	    }
		List<Map.Entry<String, Set<Integer>>> entrylist = 
				new ArrayList<Map.Entry<String, Set<Integer>>>(map.entrySet());
		Collections.sort(entrylist, new Comparator<Map.Entry<String, Set<Integer>>>() {		
			@Override
			public int compare(Entry<String, Set<Integer>> o1, Entry<String, Set<Integer>> o2) {
				return o1.getKey().compareTo(o2.getKey());
			}
		});
		for (int i = 0; i < entrylist.size(); i++) {
			System.out.println(entrylist.get(i));
		}
		sc.close();
    }
}
